package mlc.ore;

import java.util.Vector;

public class OreProvider {

	private static Vector<Ore> ores;
	
	static{
		ores = new Vector<Ore>();
		ores.add(new OreTerrain());
		ores.add(new OreIron());
		ores.add(new OreMarble());
		ores.add(new OreDullCopper());
	}
	
	public static Ore getRandomOre(int actualRow, int totalRows) {

		double reached = 0, generated = Math.random();
		Ore ore = null;
		
		for(Ore checkOre : ores){
			reached += checkOre.getSpawn();		
			if(generated <= reached) {
				ore = checkOre;
				break;
			}
		}
		//Not depth enough for this kind of ore
		if(ore != null && ore.getStartingDepth() < actualRow / totalRows)
			ore = null;

		return ore;
	}
}
